package com.xiangyi.teachingsystem.entity.po;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.xiangyi.teachingsystem.validation.groups.CourseInfo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

@Data
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Course {
    //课程标识
    @TableId(value = "id",type = IdType.AUTO)
    @NotNull(message = "id不能为空",groups = {CourseInfo.class})
    private Integer id;
    //课程名称
    @NotBlank(message = "courseName不能为空")
    private String courseName;
    //课程图片
    @NotBlank(message = "courseUrl不能为空")
    private String courseUrl;
    //课程描述
    @NotBlank(message = "courseDesc不能为空")
    private String courseDesc;
    //课程邀请码
    private String sign;

    private String courseMajor;

    private String courseSub;

    //传值，联表
    @NotNull(message = "创建课程的userId不能为空")
    @TableField(exist = false)
    private Integer userId;

    //授课教师
    @TableField(exist = false)
    private String name;

    @JsonIgnore
    public Integer getUserId() {
        return userId;
    }

    @JsonProperty
    public void setUserId(Integer userId) {
        this.userId = userId;
    }
}
